import { _goodsNew, _goodsList } from "../../../service/api";

Page({
  data: {
    bannerInfo: {},
    page: 1,
    size: 20,
    goodsList: [],
  },
  onLoad: function (options) {
    this.initData();
  },
  async initData() {
    wx.showLoading({ title: "加载中..." });
    const { bannerInfo } = await _goodsNew();
    this.setData({ bannerInfo });
    this.getGoodsList();
  },
  async getGoodsList(order = "desc", sort = "default") {
    const { page, size } = this.data;
    const res = await _goodsList({ isNew: 1, page, size, order, sort });
    this.setData({ goodsList: res.data });
    wx.hideLoading();
  },
});
